#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int dp[1010],dp2[1010],high[1010],i,n,ans1,ans2;
int main()
{
    freopen("missile.in","r",stdin);
	freopen("missile.out","w",stdout);
    while(cin>>high[n++]);
    for(int i=0;i<n;i++)
    {
        dp[i]=1;
        for(int j=0;j<i;j++)
        {
            if(high[i]<=high[j])
            {
                dp[i]=max(dp[i],dp[j]+1);
                ans1=max(ans1,dp[i]);
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        dp2[i]=1;
        for(int j=0;j<i;j++)
        {
            if(high[i]>high[j])
            {
                dp2[i]=max(dp2[i],dp2[j]+1);
                ans2=max(ans2,dp2[i]);
            }
        }
    }
    cout<<ans1-1<<endl<<ans2;
    fclose(stdin);
    fclose(stdout);
}